package com.leigq.springboot.easypoi.handler;

import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler;
import com.leigq.springboot.easypoi.param.BatchAddCustomerImportParam;
import org.springframework.stereotype.Component;

/**
 * 自定义批量加好友Excel导入验证处理
 * <br/>
 * 参考：<a href='https://blog.csdn.net/ABestRookie/article/details/113486071'>EasyPoi 导入校验使用</a>
 * @author leiguoqing
 */
@Component
public class BatchAddCustomerExcelVerifyHandler implements IExcelVerifyHandler<BatchAddCustomerImportParam> {

    /**
     * Verify handler excel verify handler result.
     *
     * @param batchAddCustomerImportParam the batch add customer dto
     * @return the excel verify handler result
     */
    @Override
    public ExcelVerifyHandlerResult verifyHandler(BatchAddCustomerImportParam batchAddCustomerImportParam) {
        // 设置默认验证为true
        final ExcelVerifyHandlerResult excelVerifyHandlerResult = new ExcelVerifyHandlerResult(true);

        final String mobile = batchAddCustomerImportParam.getMobile();

        if ("18588233764".equals(mobile)) {
            excelVerifyHandlerResult.setSuccess(false);
            excelVerifyHandlerResult.setMsg("18588233764手机号已存在，不能导出");
        }

        return excelVerifyHandlerResult;
    }
}
